<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <p>我是第一行内容</p>
        <p>我是第二行内容</p>
        <p>我是第三行内容</p>
        <p>我是第四行内容</p>
    </div>
    <button>将第二行替换为javaScript课程</button>
    <script>
        const div = document.querySelector('div');
        const btn = document.querySelector('button');
        btn.addEventListener('click',()=>{
            const p = document.createElement('p');
            p.innerHTML = 'javaScript课程';
            const ps = div.children;
            div.replaceChild(p,ps[1]);
        });
    </script>
</body>
</html>